package com.ikaros.utils;

import com.ikaros.emnus.CodeEnum;
import org.springframework.stereotype.Component;

/**
 * Created by Ikaros on 2017/9/29.
 */
@Component
public class EnumUtil {
    public static <T extends CodeEnum> T getByCode(Integer index, Class<T> enumClass){

        for (T enumT:enumClass.getEnumConstants()){
            if (enumT.getCode().equals(index)){
                return enumT;
            }
        }
       return null;
    }
}
